package com.yzt.zhuju.utils;

import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;

/**
 * author : bob
 * date   : 2022/12/1
 * desc   :
 */
public class ViewUtil {

    private static long lastClickTime;

    public static boolean isFastDoubleClick() {
        long time = System.currentTimeMillis();
        long timeD = time - lastClickTime;
        lastClickTime = time;
        return timeD <= 600;
    }

    /**
     * EditText事件
     */
    public static void addTextChangedListener(EditText editText, OnTextChangedListener listener) {
        editText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence s, int start, int count, int after) {

            }

            @Override
            public void onTextChanged(CharSequence s, int start, int before, int count) {

            }

            @Override
            public void afterTextChanged(Editable str) {
                if (listener != null) {
                    listener.callText(str.toString());
                }
            }
        });
    }

    public interface OnTextChangedListener {

        void callText(String text);
    }
}
